package com.tqjc.system.system.wrapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tqjc.system.common.Wrapper.BaseWrapper;
import com.tqjc.system.common.enums.GateRecordStatusEnum;
import com.tqjc.system.system.entity.SysGateRecordEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 86195
 * @version 1.0
 * @description TODO
 * @date 2023/9/22 16:16
 */
public class GateRecordWrapper extends BaseWrapper<SysGateRecordEntity> {

    public GateRecordWrapper(IPage<SysGateRecordEntity> pageResult) {
        super(pageResult);
        List<SysGateRecordEntity> records = pageResult.getRecords();
        List<SysGateRecordEntity> res = new ArrayList<SysGateRecordEntity>(records.size());
        for (SysGateRecordEntity record : records) {
            if(GateRecordStatusEnum.STATUS_ENTER.getStatus().equals(record.getStatus())){
                record.setStatus(GateRecordStatusEnum.STATUS_ENTER.getDesc());
            } else if(GateRecordStatusEnum.STATUS_EXIT.getStatus().equals(record.getStatus())){
                record.setStatus(GateRecordStatusEnum.STATUS_EXIT.getDesc());
            } else {
                record.setStatus(GateRecordStatusEnum.STATUS_ABNORMAL.getDesc());
            }
            res.add(record);
        }
        pageResult.setRecords(res);
    }
}
